namespace ASPNET
{
    using ASPNET.StarterKit.IssueTracker.BusinessLogicLayer;
    using System;
    using System.Diagnostics;
    using System.Runtime.CompilerServices;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public class Register : Page
    {
        [AccessedThroughProperty("btnSave")]
        private Button _btnSave;
        [AccessedThroughProperty("CompareValidator1")]
        private CompareValidator _CompareValidator1;
        [AccessedThroughProperty("lblError")]
        private Label _lblError;
        [AccessedThroughProperty("RequiredFieldValidator1")]
        private RequiredFieldValidator _RequiredFieldValidator1;
        [AccessedThroughProperty("RequiredFieldValidator2")]
        private RequiredFieldValidator _RequiredFieldValidator2;
        [AccessedThroughProperty("RequiredFieldValidator3")]
        private RequiredFieldValidator _RequiredFieldValidator3;
        [AccessedThroughProperty("txtConfirmPassword")]
        private TextBox _txtConfirmPassword;
        [AccessedThroughProperty("txtEmail")]
        private TextBox _txtEmail;
        [AccessedThroughProperty("txtPassword")]
        private TextBox _txtPassword;
        [AccessedThroughProperty("txtUsername")]
        private TextBox _txtUsername;
        private object designerPlaceholderDeclaration;

        public Register()
        {
            base.Init += new EventHandler(this.Page_Init);
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
        }

        private void Page_Init(object sender, EventArgs e)
        {
            this.InitializeComponent();
        }

        public void SaveUser(object s, EventArgs e)
        {
            if (this.Page.IsValid)
            {
                ITUser objUser = new ITUser();
                objUser.Username = this.txtUsername.Text;
                objUser.RoleName = Globals.DefaultRoleForNewUser;
                objUser.Email = this.txtEmail.Text;
                objUser.Password = this.txtPassword.Text;
                if (!objUser.Save())
                {
                    this.lblError.Text = "Could not save user";
                }
                else
                {
                    FormsAuthentication.SetAuthCookie(this.txtUsername.Text, false);
                    this.Response.Redirect("~/Issues/IssueList.aspx");
                }
            }
        }

        protected virtual Button btnSave
        {
            get
            {
                return this._btnSave;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._btnSave != null)
                {
                    this._btnSave.Click -= new EventHandler(this.SaveUser);
                }
                this._btnSave = value;
                if (this._btnSave != null)
                {
                    this._btnSave.Click += new EventHandler(this.SaveUser);
                }
            }
        }

        protected virtual CompareValidator CompareValidator1
        {
            get
            {
                return this._CompareValidator1;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._CompareValidator1 != null)
                {
                }
                this._CompareValidator1 = value;
                if (this._CompareValidator1 != null)
                {
                }
            }
        }

        protected virtual Label lblError
        {
            get
            {
                return this._lblError;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._lblError != null)
                {
                }
                this._lblError = value;
                if (this._lblError != null)
                {
                }
            }
        }

        protected virtual RequiredFieldValidator RequiredFieldValidator1
        {
            get
            {
                return this._RequiredFieldValidator1;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._RequiredFieldValidator1 != null)
                {
                }
                this._RequiredFieldValidator1 = value;
                if (this._RequiredFieldValidator1 != null)
                {
                }
            }
        }

        protected virtual RequiredFieldValidator RequiredFieldValidator2
        {
            get
            {
                return this._RequiredFieldValidator2;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._RequiredFieldValidator2 != null)
                {
                }
                this._RequiredFieldValidator2 = value;
                if (this._RequiredFieldValidator2 != null)
                {
                }
            }
        }

        protected virtual RequiredFieldValidator RequiredFieldValidator3
        {
            get
            {
                return this._RequiredFieldValidator3;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._RequiredFieldValidator3 != null)
                {
                }
                this._RequiredFieldValidator3 = value;
                if (this._RequiredFieldValidator3 != null)
                {
                }
            }
        }

        protected virtual TextBox txtConfirmPassword
        {
            get
            {
                return this._txtConfirmPassword;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._txtConfirmPassword != null)
                {
                }
                this._txtConfirmPassword = value;
                if (this._txtConfirmPassword != null)
                {
                }
            }
        }

        protected virtual TextBox txtEmail
        {
            get
            {
                return this._txtEmail;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._txtEmail != null)
                {
                }
                this._txtEmail = value;
                if (this._txtEmail != null)
                {
                }
            }
        }

        protected virtual TextBox txtPassword
        {
            get
            {
                return this._txtPassword;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._txtPassword != null)
                {
                }
                this._txtPassword = value;
                if (this._txtPassword != null)
                {
                }
            }
        }

        protected virtual TextBox txtUsername
        {
            get
            {
                return this._txtUsername;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._txtUsername != null)
                {
                }
                this._txtUsername = value;
                if (this._txtUsername != null)
                {
                }
            }
        }
    }
}

